package com.sptpc.stu.repository.my;

import com.sptpc.stu.model.my.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

public interface UserRepository extends JpaRepository<User, Long> {


    @Query(value = "SELECT * FROM table_user ORDER BY RAND() LIMIT 5 ",nativeQuery = true)
    List<User> RandomfindUser();

    Boolean existsByEmail(String email);
    Optional<User> findByAccountPhoneOrEmail(String accountPhone, String email);
    Optional<User> findByUid(Long uid);
    List<User> findUserByUid(Long uid);
    Boolean existsByAccountPhone(String phone);



    Page<User> findStudentsPageByNameLikeAndGender(String name, Boolean gender, Pageable pageable);
    List<User> findUsersPageByNameLike(String name);
    Page<User> findStudentsPageByGender(Boolean gender, Pageable pageable);

}
